﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_news_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindType();
        }

    }
    private void BindType()
    {
        ddlType.DataSource = NEWS.BLL.Menu.list();
        ddlType.DataTextField = "Title";
        ddlType.DataValueField = "Id";
        ddlType.DataBind();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        var news = new NEWS.Model.News();
        news.Title = txtTitle.Text;
        news.Menu = int.Parse(ddlType.SelectedValue);
        news.More = FreeTextBox1.Text;
        news.State = int.Parse(ddlState.SelectedValue);
        news.Adddate = DateTime.Now;
        if (NEWS.BLL.News.add(news))
        {
            NEWS.JsHelper.Alert("添加成功");
        }else
            NEWS.JsHelper.Alert("添加失败");
    }
}